package org.ms.mtx.example.service.cannel;

import org.apache.commons.lang3.StringUtils;
import org.ms.mtx.example.service.PayService;
import org.springframework.stereotype.Service;

/**
 * 支付服务
 *
 * @author lry
 */
@Service
public class PayCancelService {

    public Boolean payCancel(Integer my, String exceptionMock) {
        if (StringUtils.isNotBlank(exceptionMock) && exceptionMock.equals(Thread.currentThread().getStackTrace()[1].getMethodName())) {
            throw new RuntimeException("模拟异常:" + Thread.currentThread().getStackTrace()[1].getMethodName());
        }

        System.out.println("回滚余额:余额从[" + PayService.money.get() + "]增加为[" + PayService.money.addAndGet(my) + "]");
        return true;
    }


}
